"""
@File    : get_excel_dara.py
@Author  : qve-wzy
@Time    : 2020/9/5 0005 8:28
"""
import sys
from util.operate_excel import OperateExcel
class GetData:
    def __init__(self):
        self.opera_excel = OperateExcel()

    def get_case_lines(self):
        '''
        获取case的行数
        '''
        lines = self.opera_excel.get_rows()
        return lines

    def get_handle_step(self,row):
        '''
        获取操作步骤里面的操作方法名字
        '''
        method_name = self.opera_excel.get_cell_value(row,4)
        return method_name

    def get_element_key(self,row):
        '''
        获取操作元素的key
        '''
        element_key = self.opera_excel.get_cell_value(row,5)
        if element_key == '':
            return None
        return element_key

    def get_handle_value(self,row):
        '''
        获取操作元素的值
        '''
        handle_value = self.opera_excel.get_cell_value(row,6)
        if handle_value == '':
            return None
        return handle_value

    def get_expect_element(self,row):
        '''
        获取预期结果元素element
        '''
        expect_element = self.opera_excel.get_cell_value(row,7)
        if expect_element == '':
            return None
        return expect_element

    def get_is_run(self,row):
        '''
        获取是否需要运行
        '''
        is_run = self.opera_excel.get_cell_value(row,10)
        if is_run == 'yes':
            return True
        else:
            return False

    def get_expect_handle(self,row):
        '''
        执行
        :param row:
        :return:
        '''
        expect_step = self.opera_excel.get_cell_value(row,8)
        if expect_step == "":
            return None
        return expect_step

    def write_value(self,row,col,value):
        '''
        写入值
        :param row:
        :param col:
        :param value:
        :return:
        '''
        self.opera_excel.excel_write_data(row,col,value)

if __name__ == '__main__':
    get = GetData()
    print(get.get_case_lines())
    print(get.get_handle_step(1))
    # print(get.get_element_key(2))
    # print(get.get_handle_value(2))
    # print(get.get_expect_element(2))
    # print(get.get_is_run(2))
    # print(get.get_expect_handle(2))
    # print(get.write_value(2,10,"yes"))
